import { customRequest } from "../utils/request";

// 获得上传凭证（签名）
export interface SinatureDataResponse {
  expire: string;
  policy: string;
  signature: string;
  accessId: string;
  host: string;
  dir: string;
  callback?: string;
}
export const getSignatureData = async () => {
  return await customRequest<SinatureDataResponse>({
    method: "get",
    url: "/oss/signature",
  });
};

// 上传文件
export const uploadFileByFormData = async (
  host: string,
  formData: FormData
) => {
  return await customRequest({
    method: "post",
    url: host,
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
};
